package en.edu.cuit.aumalls.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.edu.cuit.aumalls.entity.OrderRecipients;

public interface OrderRecipientsMapper {
	
	@Select("select * from order_recipients where recipients_user = #{recipients_user}")
	public List<OrderRecipients> findAll(@Param("recipients_user") int recipients_user);
	
	@Insert("insert into order_recipients values(default,#{recipients_name},#{recipients_address},#{recipients_phone},#{recipients_user},#{recipients_checked})")
	public int insertOrderRecipients(OrderRecipients orderRecipients);
	
	@Select("select * from order_recipients where recipients_checked = 1")
	public List<OrderRecipients> findOrderRecipientsByChecked();
	
	@Update("update order_recipients set recipients_checked = 0")
	public int resetChecked();
	
	@Update("update order_recipients set recipients_checked = 1 where recipients_id = #{recipients_id}")
	public int updateChecked(@Param("recipients_id") int recipients_id);
}
